Skip to content

Fixed: surface grep/glob partial errors to callers#38

Merged
Sewer56 merged 1 commit into
mainfrom
fix/grep-glob-partial-errors
Feb 27, 2026
Merged

Fixed: surface grep/glob partial errors to callers#38
Sewer56 merged 1 commit into
mainfrom
fix/grep-glob-partial-errors

Conversation

@Sewer56
Copy link
Copy Markdown
Member

@Sewer56 Sewer56 commented Feb 27, 2026

Summary

  • fix grep and glob so per-file traversal/search failures are no longer silently dropped
  • preserve successful matches/files from readable paths while surfacing partial-state metadata (partial, errors)
  • propagate partial-state metadata through serdesAI wrappers so callers can distinguish partial results from true no-match/no-file outcomes
  • deduplicate both glob and grep return-shaping logic in shared serdesAI helpers

What Changed

  • Core grep (llm-coding-tools-core/src/tools/grep.rs)

    • capture walker entry errors instead of silently continuing
    • capture searcher.search_path(...) failures per file while preserving readable-file matches
    • extend GrepOutput with partial: bool and errors: Vec<String>
    • include a partial-results marker in formatted text output
  • Core glob (llm-coding-tools-core/src/tools/glob.rs)

    • capture walker traversal errors instead of swallowing them
    • capture strip_prefix processing failures with path context
    • extend GlobOutput with partial: bool and errors: Vec<String>
  • serdesAI wrappers

    • grep absolute/allowed wrappers emit JSON when partial with:
      • content, partial, errors, match_count, truncated
    • glob absolute/allowed wrappers emit JSON when partial with:
      • content, partial, errors, truncated
    • non-partial success behavior remains unchanged (plain text unless truncated)
  • Dedup follow-ups

    • moved duplicated glob conversion code to llm-coding-tools-serdesai/src/common/glob.rs
    • moved duplicated grep conversion code to llm-coding-tools-serdesai/src/common/grep.rs
    • absolute and allowed variants now reuse shared conversion helpers for consistency

Commit

  • e77d318 — Fixed: Surface grep/glob partial errors end-to-end

Behavior Notes

  • hard failures remain reserved for invalid top-level inputs (invalid regex/glob/root path)
  • per-file traversal/read/search failures now produce explicit partial metadata instead of silent zero-result output
  • existing readable-file success paths keep their previous semantics

Testing

  • cargo fmt
  • .cargo/verify.sh
    • build/test/clippy/doc all pass
    • script still fails at cargo publish --dry-run -p llm-coding-tools-agents because crates.io currently cannot resolve llm-coding-tools-core = ^0.2.0 (pre-existing publish environment issue)

Review

  • @coderabbit review run on committed changes; no findings

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 27, 2026

Warning

Rate limit exceeded

@Sewer56 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 38 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 0d7ca3b and 3db04e8.

📒 Files selected for processing (9)
  • src/llm-coding-tools-core/src/tools/glob.rs
  • src/llm-coding-tools-core/src/tools/grep.rs
  • src/llm-coding-tools-serdesai/src/absolute/glob.rs
  • src/llm-coding-tools-serdesai/src/absolute/grep.rs
  • src/llm-coding-tools-serdesai/src/allowed/glob.rs
  • src/llm-coding-tools-serdesai/src/allowed/grep.rs
  • src/llm-coding-tools-serdesai/src/common/glob.rs
  • src/llm-coding-tools-serdesai/src/common/grep.rs
  • src/llm-coding-tools-serdesai/src/common/mod.rs

Walkthrough

This PR extends glob and grep tools to track and report partial results and processing errors. In the core libraries, GlobOutput and GrepOutput now expose partial (bool) and errors (Vec) fields to indicate traversal and processing issues. The glob_files and grep_search functions accumulate error messages instead of silently failing. In the serdesai modules, both absolute and allowed variants now emit JSON payloads when partial results occur, including content, error metadata, and truncation information, while maintaining plain text output for successful operations.

Possibly related PRs

  • PR #5: Directly extends the same structures (GlobOutput/GrepOutput) and serdesai conversion logic introduced in that PR with error tracking capabilities.
  • PR #1: Modifies the same underlying glob and grep implementations that this PR enhances with partial result and error reporting.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: surfacing grep/glob partial errors to callers instead of silently dropping them.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The PR description comprehensively covers the changes, objectives, testing performed, and includes a clear summary of modifications across all affected files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/grep-glob-partial-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/llm-coding-tools-core/src/tools/glob.rs`:
- Around line 60-63: The push of format!("walk error: {err}") into the errors
Vec leaks filesystem paths; change both places that push this string (the
Err(err) arms that currently use format!("walk error: {err}")) to redact path
details by logging only a non-path error kind or a generic message (e.g., use
err.io_error().kind() or err.kind() if using walkdir::Error, or replace with
"walk error: <redacted>" / "walk error: <IO error: PermissionDenied>" ), so the
errors Vec never contains concrete filesystem paths; update both occurrences
referenced in glob.rs (the Err(err) arms).

In `@src/llm-coding-tools-core/src/tools/grep.rs`:
- Around line 145-148: The error string currently embeds the raw filesystem
error (format!("walk error: {err}")) which can leak host paths; change these to
sanitize/remove path details by replacing the embedded error text with a
non-path-specific token such as the IO error kind or a generic message (e.g.,
format!("walk error: {}", err.kind()) or simply "walk error") wherever
errors.push(...) is used in this file (the occurrences around the shown snippet
and the later block at lines ~237-251). Ensure you do the same substitution for
all similar pushes in grep.rs so callers no longer receive raw filesystem path
information.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68e1289 and 0d7ca3b.

📒 Files selected for processing (6)
  • src/llm-coding-tools-core/src/tools/glob.rs
  • src/llm-coding-tools-core/src/tools/grep.rs
  • src/llm-coding-tools-serdesai/src/absolute/glob.rs
  • src/llm-coding-tools-serdesai/src/absolute/grep.rs
  • src/llm-coding-tools-serdesai/src/allowed/glob.rs
  • src/llm-coding-tools-serdesai/src/allowed/grep.rs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build and Test (Async/Tokio) (ubuntu-latest, x86_64-unknown-linux-gnu, false)
  • GitHub Check: Build and Test (Blocking) (macos-latest, aarch64-apple-darwin, false)
  • GitHub Check: Build and Test (Blocking) (windows-latest, x86_64-pc-windows-msvc, false)
  • GitHub Check: Build and Test (Async/Tokio) (macos-latest, aarch64-apple-darwin, false)
  • GitHub Check: Build and Test (Async/Tokio) (windows-latest, x86_64-pc-windows-msvc, false)
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.rs

📄 CodeRabbit inference engine (src/AGENTS.md)

src/**/*.rs: Preallocate collections when size is known or estimable using String::with_capacity(estimated_len), Vec::with_capacity(count), or BufReader::with_capacity(size, reader)
Prefer &str / &[T] returns over owned types when lifetime allows
Use Cow<'_, str> for conditional ownership (e.g., String::from_utf8_lossy)
Use &'static str for compile-time constant strings
Reuse buffers by calling .clear() and reusing Vec/String instead of reallocating
Use const generics for compile-time branching (e.g., <const LINE_NUMBERS: bool>)
Use #[inline] on small, hot-path functions
Prefer core over std where possible (e.g., core::mem over std::mem)
Use memchr crate for fast byte searching over manual iteration
Keep modules under 500 lines (excluding tests); split if larger
Place use statements inside functions only for #[cfg] conditional compilation
Document public items with /// and add examples in docs where helpful
Use //! for module-level documentation
Use [TypeName] rustdoc links instead of backticks in documentation

Files:

  • src/llm-coding-tools-serdesai/src/absolute/grep.rs
  • src/llm-coding-tools-serdesai/src/absolute/glob.rs
  • src/llm-coding-tools-serdesai/src/allowed/glob.rs
  • src/llm-coding-tools-core/src/tools/grep.rs
  • src/llm-coding-tools-core/src/tools/glob.rs
  • src/llm-coding-tools-serdesai/src/allowed/grep.rs
🧠 Learnings (3)
📚 Learning: 2026-02-07T22:53:26.067Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-02-07T22:53:26.067Z
Learning: Organize code with `llm-coding-tools-serdesai/` containing `src/absolute/`, `src/allowed/`, `src/schema.rs`, and `src/convert.rs` for serdesAI framework implementations

Applied to files:

  • src/llm-coding-tools-serdesai/src/absolute/grep.rs
  • src/llm-coding-tools-serdesai/src/absolute/glob.rs
  • src/llm-coding-tools-serdesai/src/allowed/glob.rs
  • src/llm-coding-tools-serdesai/src/allowed/grep.rs
📚 Learning: 2026-02-07T22:53:26.067Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-02-07T22:53:26.067Z
Learning: Applies to src/**/*.rs : Document public items with `///` and add examples in docs where helpful

Applied to files:

  • src/llm-coding-tools-serdesai/src/absolute/grep.rs
  • src/llm-coding-tools-serdesai/src/absolute/glob.rs
  • src/llm-coding-tools-serdesai/src/allowed/glob.rs
  • src/llm-coding-tools-core/src/tools/glob.rs
📚 Learning: 2026-02-07T22:53:26.067Z
Learnt from: CR
Repo: Sewer56/llm-coding-tools PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2026-02-07T22:53:26.067Z
Learning: Organize code with `llm-coding-tools-core/` as framework-agnostic core library containing `src/tools/`, `src/path/`, `src/error.rs`, `src/output.rs`, and `src/util.rs`

Applied to files:

  • src/llm-coding-tools-serdesai/src/absolute/grep.rs
  • src/llm-coding-tools-serdesai/src/absolute/glob.rs
  • src/llm-coding-tools-serdesai/src/allowed/glob.rs
  • src/llm-coding-tools-serdesai/src/allowed/grep.rs
🧬 Code graph analysis (3)
src/llm-coding-tools-serdesai/src/absolute/glob.rs (4)
src/llm-coding-tools-core/src/tools/glob.rs (1)
  • glob_files (31-123)
src/llm-coding-tools-serdesai/src/convert.rs (1)
  • to_serdes_result (51-58)
src/llm-coding-tools-serdesai/src/allowed/glob.rs (3)
  • output_content (15-21)
  • glob_output_to_return (24-44)
  • partial_glob_output_returns_json_payload (171-182)
src/llm-coding-tools-core/src/output.rs (1)
  • truncated (29-34)
src/llm-coding-tools-serdesai/src/allowed/glob.rs (4)
src/llm-coding-tools-core/src/tools/glob.rs (1)
  • glob_files (31-123)
src/llm-coding-tools-serdesai/src/convert.rs (1)
  • to_serdes_result (51-58)
src/llm-coding-tools-serdesai/src/absolute/glob.rs (3)
  • output_content (15-21)
  • glob_output_to_return (24-44)
  • partial_glob_output_returns_json_payload (148-159)
src/llm-coding-tools-core/src/output.rs (1)
  • truncated (29-34)
src/llm-coding-tools-core/src/tools/glob.rs (1)
src/llm-coding-tools-core/src/tools/grep.rs (2)
  • format (69-104)
  • output (304-304)
🔇 Additional comments (23)
src/llm-coding-tools-serdesai/src/allowed/grep.rs (3)

9-9: serde_json::json import is a clean fit for structured partial responses.


126-136: Partial grep outcomes are correctly promoted to structured payloads.

This preserves readable formatted content while exposing partial/errors/match_count/truncated for robust caller handling.


227-252: Good test coverage for the new partial JSON response path.

src/llm-coding-tools-serdesai/src/absolute/glob.rs (4)

4-10: Import updates look correct for the new glob output mapping path.


14-44: Helper extraction for content/render branching is clear and maintainable.


96-99: Result handling now cleanly separates core error conversion from output shaping.


147-159: The new unit test correctly validates partial JSON payload semantics.

src/llm-coding-tools-serdesai/src/absolute/grep.rs (3)

9-9: serde_json::json import is appropriate for the new structured return branch.


120-130: Partial grep handling is correctly surfaced as JSON with full metadata.


263-289: Nice test addition for partial/error JSON behavior on search failures.

src/llm-coding-tools-serdesai/src/allowed/glob.rs (4)

4-10: Import changes are coherent with the new structured glob output path.


14-44: The helper-based output conversion is straightforward and easy to reason about.


102-105: The updated match branch cleanly preserves error mapping and formats success outputs consistently.


170-182: Good focused unit test for partial JSON payload behavior.

src/llm-coding-tools-core/src/tools/glob.rs (4)

20-25: GlobOutput metadata extension is clean and well-documented.


48-48: Nice preallocation for the error buffer in the traversal loop.


117-122: Partial/error propagation in the final GlobOutput is correctly wired.


223-250: Serialization tests for partial metadata are solid and targeted.

src/llm-coding-tools-core/src/tools/grep.rs (5)

50-55: GrepOutput now carrying partial/error metadata is a good API evolution.


95-101: Partial-results marker in formatter is a useful human-readable signal.


133-134: Good call preallocating the error accumulator.


170-220: The new FileSearchResult flow correctly keeps matches while accumulating partial errors.


294-337: Great additions for partial-formatting and error-path tests.

Comment thread src/llm-coding-tools-core/src/tools/glob.rs
Comment thread src/llm-coding-tools-core/src/tools/grep.rs
@Sewer56 Sewer56 force-pushed the fix/grep-glob-partial-errors branch from 0952beb to e77d318 Compare February 27, 2026 19:40
Capture per-file traversal and search failures in core grep/glob as structured partial metadata (partial, errors) instead of silently dropping them.

Propagate partial state through serdesAI absolute/allowed wrappers using explicit JSON payloads while preserving existing non-partial text behavior.

Deduplicate wrapper conversion logic by extracting shared helpers in common::glob and common::grep so absolute and allowed variants stay consistent.
@Sewer56 Sewer56 force-pushed the fix/grep-glob-partial-errors branch from e77d318 to 3db04e8 Compare February 27, 2026 19:51
@Sewer56 Sewer56 merged commit c4b8afc into main Feb 27, 2026
6 checks passed
@Sewer56 Sewer56 deleted the fix/grep-glob-partial-errors branch February 27, 2026 19:53
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 65.85366% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.25%. Comparing base (68e1289) to head (3db04e8).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/llm-coding-tools-core/src/tools/glob.rs 40.00% 9 Missing ⚠️
src/llm-coding-tools-serdesai/src/absolute/grep.rs 0.00% 4 Missing ⚠️
src/llm-coding-tools-serdesai/src/allowed/grep.rs 0.00% 4 Missing ⚠️
src/llm-coding-tools-serdesai/src/common/glob.rs 76.47% 4 Missing ⚠️
src/llm-coding-tools-serdesai/src/absolute/glob.rs 0.00% 3 Missing ⚠️
src/llm-coding-tools-serdesai/src/allowed/glob.rs 0.00% 3 Missing ⚠️
src/llm-coding-tools-core/src/tools/grep.rs 95.83% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
- Coverage   75.25%   75.25%   -0.01%     
==========================================
  Files          65       67       +2     
  Lines        1924     1964      +40     
==========================================
+ Hits         1448     1478      +30     
- Misses        476      486      +10     
Flag Coverage Δ
unittests 75.25% <65.85%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/llm-coding-tools-serdesai/src/common/grep.rs 100.00% <100.00%> (ø)
src/llm-coding-tools-core/src/tools/grep.rs 90.00% <95.83%> (-4.94%) ⬇️
src/llm-coding-tools-serdesai/src/absolute/glob.rs 18.75% <0.00%> (-19.35%) ⬇️
src/llm-coding-tools-serdesai/src/allowed/glob.rs 14.28% <0.00%> (-22.56%) ⬇️
src/llm-coding-tools-serdesai/src/absolute/grep.rs 17.50% <0.00%> (+0.42%) ⬆️
src/llm-coding-tools-serdesai/src/allowed/grep.rs 5.00% <0.00%> (+0.12%) ⬆️
src/llm-coding-tools-serdesai/src/common/glob.rs 76.47% <76.47%> (ø)
src/llm-coding-tools-core/src/tools/glob.rs 76.59% <40.00%> (-3.41%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant